# encoding=utf-8
a1= {}
b1 = {'a':'bb'}
a1.update(b1)
c1= {'aa':'bbb'}
a1.update(c1)


a1= [1,2,3]
b1 = str(a1)
c1 = list(b1)

d1 = list(eval(b1))

#1、字典
dict = {'name':'lck','age':30,'class':'master','level':'high'}

#字典转化为字符串
dict_str = str(dict)
print str(dict)
print type(str(dict))

#字典转化为元组
dict_tuple = tuple(dict)
print tuple(dict)
print type(tuple(dict))

#字典转换为列表
dict_tuple_value = tuple(dict.values())
dict_tuple_key = tuple(dict.keys())
print dict_tuple_value
print dict_tuple_key
print type(dict_tuple_key)


#2、元组
tup = (1,2,3,4)
#元组转化为字符串
tuple_str = str(tup)
print tuple_str
#元组转化为列表
tuple_list = list(tup)
print tuple_list

#元组转化为字典    不可以



#3、列表
nums = [1,2,3,'fff']
#列表转化为字符串
nums_str = str(nums)
print nums_str

#列表转化为元组
nums_tuple = tuple(nums)
print nums_tuple

#列表转化为字典   不可以



#4、字符串
aa = "('a','b','c','c')"
a1 = "['a','b','c','c']"
bb = "{'e':1,'v':9,'d':9}"
cc = "[{'e':9,'d':0},{'d':8,'r':7}]"
#字符串转化为元组
aa_tuple1 = tuple(eval(aa))
print aa_tuple1
a1_tuple = tuple(eval(a1))
print a1_tuple
#字符串转化为列表
aa_list = list(eval(aa))
bb_list = list(eval(bb))
cc_list = list(eval(cc))
print aa_list
print bb_list
print cc_list

#字符串转化为字典
aa_dic = eval(aa)
bb_dic = eval(bb)
cc_dic = eval(cc)

print aa_dic
print bb_dic
print cc_dic















